<?php
require './RunDbPdo.php';
require './MmCache.php';
$model = new RunDbPdo();
$mem  = new MmCache();
extract($_GET);
$user_id = isset($user_id)?$user_id:0;
$slice = $user_id%2;
$model->configFile = "./dbconfig/user{$slice}.config.php";
$sql = "SELECT * FROM mm_users{$slice} WHERE user_id={$user_id}";
$key = "{user_id:$user_id}";
$data = $mem->get($key);
if(empty($data)){
    $data = $model->getRow($sql);//查询
    $mem->set($key, $data, 3600);
}
?>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta charset="utf-8">
    <title>用户管理系统</title>
    <link href="./css/property-system.css" rel="stylesheet">
    <link href="./css/operate-system.css" rel="stylesheet">
        </head>
        <body>
            <main>
                <section class="content">
                    <header class="content-header">查看用户</header>
                    <div class="box">
                    <table class="tab-list-1 tab-list-break">
                        <colgroup>
                            <col style="width:auto">
                            <col style="width:auto">
                            <col style="width:auto">
                            <col style="width:auto">
                            <col style="width:auto">
                            <col style="width:auto">
                            <col style="width:auto">
                            <col style="width:auto">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>用户ID</th>
                            <th>用户名</th>
                            <th>年龄</th>
                            <th>地址</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td><?=isset($data['user_id'])?$data['user_id']:0?></td>
                            <td><?=isset($data['username'])?$data['username']:''?></td>
                            <td><?=isset($data['age'])?$data['age']:''?></td>
                            <td><?=isset($data['address'])?$data['address']:''?></td>
                            <td>
				<a href="edit.php?user_id=<?=isset($data['user_id'])?$data['user_id']:0?>">编辑</a>
				<a href="select.php?user_id=<?=isset($data['user_id'])?$data['user_id']:0?>">查看</a>
				<a href="delete.php?user_id=<?=isset($data['user_id'])?$data['user_id']:0?>">删除</a>
			    </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
                </section>
            </main>
    </body>
</html>